	<!--  Ajax Scripts -->
	<%@page import="net.groupme.gui.rendering.constants.RENDERING_CONSTANTS"%>
	<%@page import="net.groupme.group.GroupManager"%>
	<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
	<%@page import="net.groupme.gui.constants.VIEW_VOCABULARY"%>
	<%@page import="java.util.Iterator"%>
	<%@page import="net.groupme.model.User"%>	
	<%@page import="java.util.Collection"%>
	<%@page import="net.groupme.model.Group"%>
	<%@page import="net.groupme.model.MODEL_CONSTANTS"%>
	<%@page import="net.groupme.model.Tag"%>
	<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRSearchManager.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRGroupManager.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRUserManager.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'> </script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRGroupBrowsingManager.js'></script>
	<script type="text/javascript" language="javascript"><!--
<%	GroupManager groupManager = (GroupManager) WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext()).getBean(VIEW_VOCABULARY.GROUP_MANGER, GroupManager.class);	
	Iterator it = groupManager.getGroup().getUsers(MODEL_CONSTANTS.ROLE_OWNER).iterator();
	User user = null;
	while(it.hasNext()){
		user= (User)it.next();	
	}
	
	Collection<Group> groupsOfUser = user.getGroups(MODEL_CONSTANTS.ROLE_OWNER);
	Collection<Group> subscriptionsOfUser = user.getGroups(MODEL_CONSTANTS.ROLE_SUBSCRIBER);
	
	Iterator jt = groupManager.getGroup().getTags().iterator();
	String groupTags = "";
	while(jt.hasNext()){
		Tag tag = (Tag)jt.next();
		
		String keyword=StringEscapeUtils.escapeHtml(tag.getKeyword());
		
		groupTags+= "<a href=\"" + tag.getURI() + "\" "+  " title=\"Search for groups and resources related with " + keyword + "\"> "  + keyword + "</a>"; 
	}

%>

		/** the Id of the group currently selected */
		var currentGroupId = <%=((GroupManager) WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext()).getBean(VIEW_VOCABULARY.GROUP_MANGER, GroupManager.class)).getGroupID()%>;

		/**
		 * Reload tag cloud of group.
		 */
		function reloadTagCloud(){
		 	DWRGroupManager.getGroupTagCloud(showTagCloud);
		 	$('tagcloudForGroupBrowsing').update($('tagcloudForGroupBrowsing').innerHTML + "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/> <small><i>refreshing tag cloud</i></small>");
	 	}
	 	
		/**
		 * Visualize tag cloud of group.
		 */
		function showTagCloud(tagCloud){
		 	if(tagCloud == null || tagCloud.html == ""){
		 		$('tagcloudForGroupBrowsing').update("<i>Neither the group nor its resources are tagged!</i>");
		 	}else{
		 		$('tagcloudForGroupBrowsing').update("<strong><small>Tag Cloud:</small></strong> <br>" + tagCloud.html);
	 		}
	 	}
	 	
	 	/**
		* This method is for showing the similar groups for the current vied group.
		*/
		function getSimilarGroups(){
			DWRGroupBrowsingManager.getSimilarGroups(currentGroupId, getSimilarGroupsCallback);
		}
		
		/**
		* The Callback function for getSimilarGroups, sets the similar groups.
		* @param array of HTMLFormattedElements, representing the similar groups.
		*/
		function getSimilarGroupsCallback(similars){
			var tmpHTML = "<strong><small>Similar Groups: </small></strong> <br/>";
			for(var i=0; i<similars.size(); i++){
				tmpHTML += similars[i].html;
			}
			$('similarGroups').update(tmpHTML);
		}
		
		getSimilarGroups();
		//-->
	</script>
<div id="groupSidebarContent">
	<div id="groupTagcloudAndSimilar">
		<div id ="groupTags">
		<strong><small>GroupTags:</small></strong><br>
		<%=groupTags%>
		</div>
		<div id="tagcloudForGroupBrowsing"> 
			<strong>Tag Cloud:</strong>
			<br>
			<script type="text/javascript" language="javascript">
			reloadTagCloud()
			</script>
		</div>
		<div id="similarGroups">
		</div>
		
	</div>
	<div id = "groupMetaInformation">
		<br>
	 	Created: <%=groupManager.getGroup().getDateCreated().substring(0,10) %>
		<br>
	 	<%=groupManager.getGroup().getDescription() %>
	 	<% 
		Collection<User> contributors = groupManager.getGroup().getUsers(MODEL_CONSTANTS.ROLE_EDITOR);
		String contributorString = null;
		for(User contributor: contributors){
			if(contributorString == null){
				contributorString = "<br/>Contributors: "; 
			}
			contributorString += "<a href=\"" + contributor.getURI() + "\">" + contributor.getUserName() + "</a> "; 
		}
		if(contributorString == null){
			contributorString = "";
		}
		%>
		<%= contributorString %>
	</div>
	<div id="userDetails"> 
		<br>
		<div id="userPhoto">
		<div style=" background-image:url(<%=request.getContextPath()%>/images/user_bg.png); background-repeat:no-repeat; height:85px; width:85px;">
			<% if(user.getPhoto() != null && !"".equals(user.getPhoto())){ %>		
			<img src=<%= user.getPhoto() %> width="70" height="70" border="0" alt="Userfoto"/>
			<%}else{ %>
			<img src=<%= VIEW_VOCABULARY.STANDARD_USER_ICON %> width="70" height="70" border="0" alt="Userfoto"/>
			<%} %>
		</div>
		</div>
		<div id="userStats" >
			<a href=<%= VIEW_VOCABULARY.RESTful_USER_URI_PATTERN %><%=user.getUserName()%>  title="view user page">  <%= user.getUserName()%>  
			</a>
			<br>	
			groups: <%=groupsOfUser.size() %>
			<br>
			tags: <%=user.getTags().size() %>
		</div>		
	</div>
</div>



